<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<script>
$(function(){
$('#search').click(function(){
	document.workOrderForm.submit();
});
});
</script>
${pu:reqSet('pageable_currentPage', param.tpp_pageable_currentPage) }
<c-rt:if test="${empty param.tpp_pageable_currentPage}">
${pu:reqSet('pageable_currentPage', 1) }
</c-rt:if>
<c-rt:set var="tp" value="${pu:pageableTag('tpp', 20, 10)}"/>
<c-rt:if test="${empty param.keyword}">
	${pu:reqSet('results', pu:queryByHql('from User order by username asc', null, tp)) }
</c-rt:if>
<c-rt:if test="${!empty param.keyword}">
	<c-rt:set var="hql">
	from User where username like ? or nameNative like ? order by createDate desc
	</c-rt:set>
	<c-rt:set var="keyword">
	%${param.keyword }%
	</c-rt:set>
	<c-rt:set var="params" value="${pu:addToList('paras', keyword)}"/>
	<c-rt:set var="params" value="${pu:addToList('paras', keyword)}"/>
	<c-rt:set var="results" value="${pu:queryByHql(hql, params, tp)}"/>
</c-rt:if>

<div class="f-link"><a href="/ecadmin/cs/taskGroup/page.do?iamlazy=list" id="list">任務群組管理</a></div>
<h1>任务分组管理-使用者列表

</h1>
<form name="workOrderForm" id="workOrderForm" method="post" action="/ecadmin/cs/taskGroup/page.do">
<input type="hidden" name="iamlazy" value="userList"/>
<table>
<tr>
<td>关键字:<input type="text" value="${param.keyword }" name="keyword"/></td><td><div class="f-link"><a href="javascript:;" id="search">search</a></div></td>
</tr>
</table>
</form>

<table class="tb-1" width="100%">
		<thead>
			<tr>
				<th></th>
				<th>登入代码</th>
				<th>姓名</th>
				<th>电子邮件</th>
				<th>所属分组</th>
			</tr>
		</thead>
		<tbody>
			<c-rt:forEach items="${results}" var="result" varStatus="rows_index">
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
					<td>
					
					</td>
					<td>${result.username }</td>
					<td>${result.nameNative }</td>
					<td>${result.email }</td>
					<td>
					${pu:reqSet('theparams', null) }
					${pu:listAdd('theparams', result.username) }
					${pu:reqSet('groups', pu:queryByHql('from TaskGroupUser where user.username=?', pu:arrayGet('theparams'), null)) }
					<c-rt:forEach items="${groups }" var="group">
					<table width="300"><tr><td align="left" width="120"  style="text-align:left">
					${group.taskGroup.name } <c-rt:if test="${group.defaultGroup}">(主要)</c-rt:if>
					</td><td align="left" style="text-align:left">
					<input type="button" value="移除" onclick="if(confirm('确定移除？')){location.href='/ecadmin/cs/taskGroup/deleteGroupUser.do?groupUserId=${group.id}&tpp_pageable_currentPage=${pageable_currentPage }&keywod=${param.keyword }';}"/>
					<c-rt:if test="${!group.defaultGroup}">
					<input type="button" value="设为主要" onclick="location.href='/ecadmin/cs/taskGroup/setDefaultGroup.do?username=${group.user.username}&groupUserId=${group.id }&tpp_pageable_currentPage=${pageable_currentPage }&keyword=${param.keyword }';"/><br/>
					</c-rt:if>
					</td></tr></table>
					</c-rt:forEach>
					</td>
				</tr>
			</c-rt:forEach>
		</tbody>
	</table>
<c-rt:set var="url">
<%=application.getContextPath() %>/cs/taskGroup/page.do?iamlazy=userList
</c-rt:set>
<pageable:Pageable url="${url}" escapeparams="iamlazy,AJAX,refreshZone" parameter="refreshZone=main" formname="csForm" key="tpp"></pageable:Pageable>
